<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Rag Hu
 * Created Time: 2019/6/29 13:40
 * Modified Time: 2019/6/29 13:40
 * Version: 2.0
 */

namespace App\Modules\MemberCard\Validators;


use Flower\Core\Repository\Contracts\ValidatorInterface;
use Flower\Core\Repository\Validator\LaravelValidator;

class CardTypeValidator extends LaravelValidator
{
    protected $rules = [
        ValidatorInterface::RULE_CREATE => [
            'store_id' => 'required|numeric',
            'category' => 'required|min:1|max:2',
            'price' => 'required|numeric|min:1|max:99999',
            'name' => 'required|between:2,16',
            'present' => 'required_if:category,2|numeric|min:0|max:99999',
            'royalty' => 'required|numeric|min:0|max:100',
            'count' => 'required_if:category,1|numeric|min:0|max:99999',
            'discount_way' => 'required'
        ],

        ValidatorInterface::RULE_UPDATE => [
            'category' => 'filled|min:1|max:2',
            'price' => 'filled|numeric|min:1|max:99999',
            'name' => 'filled|between:2,16',
            'present' => 'filled|numeric|min:0|max:99999',
            'royalty' => 'filled|numeric|min:0|max:100',
            'count' => 'filled|numeric|min:0|max:99999',
            'discount_way' => 'filled'
        ],

    ];
    protected $messages = [
        'store_id.required' => '店铺id不能为空',
        'store_id.numeric' => '店铺id格式错误',

        'category.required' => '请选择会员卡类型',
        'category.min' => '卡类格式错误',
        'category.max' => '卡类格式错误',

        'price.required' => '请选择会员卡价格',
        'price.numeric' => '会员卡价格格式错误',
        'price.min' => '会员卡价格不能低于1元',
        'price.max' => '会员卡价格不能高于99999元',


        'present.required_if' => '请选择会员卡赠额',
        'present.numeric' => '会员卡赠额格式错误',
        'present.min' => '会员卡赠额不能低于1元',
        'present.max' => '会员卡赠额不能高于99999元',


        'count.required_if' => '请选择会员卡次数',
        'count.numeric' => '会员卡次数格式错误',
        'count.min' => '会员卡次数不能低于1次',
        'count.max' => '会员卡次数不能高于99999次',

        'royalty.required' => '请选择会员卡提成',
        'royalty.numeric' => '会员卡提成格式错误',
        'royalty.min' => '会员卡提成不能低于0%',
        'royalty.max' => '会员卡提成不能高于100%',

    ];
}